﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Trade.Journal
{
    /// <summary>
    /// ViewByDateCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class ViewByDateCtrl : UserControl
    {
        public ViewByDateCtrl()
        {
            InitializeComponent();
        }

        private void RecordDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var win = new ViewRecordWindow();
            win.Owner = Application.Current.MainWindow;
            win.Load((sender as ListViewItem)?.Content as Record);
            win.ShowDialog();
        }
    }





    public class ViewByDateCtrlViewModel:BindableBase
    {

        public ObservableCollection<Record> DataCollection { get; set; }



        private Record[] _Records;

        public Record[] Records
        {
            get { return _Records; }
            set { SetProperty(ref _Records, value); }
        }






        public ViewByDateCtrlViewModel()
        {
            DataCollection = new ObservableCollection<Record>(DataShop.Records);

            Records = DataShop.Records;
            DataShop.RecordsChanged += () => { Records = DataShop.Records; };
        }



    }
}
